package com.share.domain.learn;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

/**
 * @author caifan
 * 2018/6/24
 */
/*
//springboot2.2以下 es7及以下
@Data
@Document(indexName = "user_index", type = "user", shards = 3, replicas = 2, indexStoreType = "fs")
public class User implements Serializable {
    private static final long serialVersionUID = -3031200458373794781L;
    @Id
    private Long id;
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    @Field(type = FieldType.Date, format = DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
    private Date deleteTime;
    private String nickname;
    private Integer age;
    private String email;
    private Date lastLoginTime;
    @Field
    private String username;
    @Field
    private String cardNo;
    private Integer status;
}*/
@Data
@Document(indexName = "user_index", type = "user")
public class User implements Serializable {
    private static final long serialVersionUID = -3031200458373794781L;
    @Id
    private Long id;
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat (shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;
    @Field(type = FieldType.Date, format = DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat (shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;
    private Date deleteTime;
    private String nickname;
    private Integer age;
    private String email;
    private Date lastLoginTime;
    @Field(type = FieldType.Text)
    private String username;
    @Field(type = FieldType.Text)
    private String cardNo;
    private Integer status;
}
